'use strict'

import HybridJS from '../core/core'

const $ = HybridJS

/**
 * 此api为base64图片保存到本地临时文件夹
 * @param {*} base64Str 
 * @param {*} fileName 
 * @param {*} fn 
 */
function saveImgToTemp(base64Str,fileName,fn) {
    $.callNative("file","saveImgToTemp",{"base64Str":base64Str,"fileName":fileName,"callback":fn})
}

/**
 * 此api为base64图片保存到本地相册系统
 * 返回结果success:true/false,filePath:(成功后本地的存储路径)
 * @param {*} base64Str 
 * @param {*} fileName 
 * @param {*} fn 
 */
function saveImgToPhotosAlbum(base64Str,fileName,fn) {
    $.callNative("file","saveImgToPhotosAlbum",{"base64Str":base64Str,"fileName":fileName,"callback":fn})
}

/**
 * 此api为网络图片保存到本地临时文件夹
 * @param {*} url 
 * @param {*} fn 
 */
function downloadImgToTemp(url,fn) {
    $.callNative("file","downloadImgToTemp",{"url":url,"callback":fn})
}

/**
 * 此api为网络图片保存到本地系统相册
 * @param {*} url 
 * @param {*} fn 
 */
function downImgToPhotosAlbum(url,fn) {
    $.callNative("file","downImgToPhotosAlbum",{"url":url,"callback":fn})
}

export default {
    saveImgToTemp,
    saveImgToPhotosAlbum,
    downloadImgToTemp,
    downImgToPhotosAlbum
}